package com.crl.module.commands
{
	import com.crl.core.ICommand;
	
	import flash.events.Event;
	
	
	/**
	 *  以队列形式 处理已注册的映射类;
	 * @author crl;
	 * 
	 */	
	public class QueueableTaskExecutor extends QueueableTask implements ICommand
	{
		private var taskList:Vector.<QueueableTask>
		public function QueueableTaskExecutor(tasks:Vector.<QueueableTask>)
		{
			this.taskList=tasks;
		}
		
		override public function execute(e:*=null) : void{
			if(this.taskList.length){
				this.onComplete();
				return;
			}
			
			var task:QueueableTask = this.taskList.shift();
			task.addEventListener(Event.COMPLETE, onComplete);
			task.execute();
			
		}
		
		override protected function onComplete() : void{
			this.execute();
		} 
		
	}
}